package pcjavanet.mobilesell.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import pcjavanet.mobilesell.model.History;
import pcjavanet.mobilesell.model.PageBean;
import pcjavanet.mobilesell.model.QryCondition;
import pcjavanet.mobilesell.service.HistoryService;

import com.opensymphony.xwork2.ActionSupport;
@Namespace("/history")
@Controller
@Scope("prototype")
@ParentPackage("json-default")
@Results({
	@Result(name = "success", location = "/view/History.jsp"),
	@Result(name = "input", location = "/view/History.jsp")
})

public class HistoryAction  extends ActionSupport {

  @Resource
  private HistoryService historyService;
  private   java.lang.Integer dbid ;
  private   java.lang.String datestr ;
  private   java.lang.String typestring ;
  private   java.lang.String serialnumber ;
  private   java.lang.Double price ;
  private   java.lang.String peijian ;
  private   java.lang.Integer refStorehouseDbid ;
  private   java.util.Date createDate ;
  private int start  ;
  private int limit  ;
  private int totalProperty  ;
  private boolean success = true ;
  private String  info ;
  private List<History>  historyPageBeans  ;
  public    java.lang.Integer getDbid() {
   	return this.dbid;
  }
  public void setDbid(  java.lang.Integer  dbid) {
   	 this.dbid=dbid;
  }
  public    java.lang.String getDatestr() {
   	return this.datestr;
  }
  public void setDatestr(  java.lang.String  datestr) {
   	 this.datestr=datestr;
  }
  public    java.lang.String getTypestring() {
   	return this.typestring;
  }
  public void setTypestring(  java.lang.String  typestring) {
   	 this.typestring=typestring;
  }
  public    java.lang.String getSerialnumber() {
   	return this.serialnumber;
  }
  public void setSerialnumber(  java.lang.String  serialnumber) {
   	 this.serialnumber=serialnumber;
  }
  public    java.lang.Double getPrice() {
   	return this.price;
  }
  public void setPrice(  java.lang.Double  price) {
   	 this.price=price;
  }
  public    java.lang.String getPeijian() {
   	return this.peijian;
  }
  public void setPeijian(  java.lang.String  peijian) {
   	 this.peijian=peijian;
  }
  public    java.lang.Integer getRefStorehouseDbid() {
   	return this.refStorehouseDbid;
  }
  public void setRefStorehouseDbid(  java.lang.Integer  refStorehouseDbid) {
   	 this.refStorehouseDbid=refStorehouseDbid;
  }
  public    java.util.Date getCreateDate() {
   	return this.createDate;
  }
  public void setCreateDate(  java.util.Date  createDate) {
   	 this.createDate=createDate;
  }
  public  void setStart(int start) {
   	 this.start = start;
  }
  public  void setLimit(int limit) {
   	 this.limit = limit;
  }
  public  void setTotalProperty(int totalProperty) {
   	 this.totalProperty = totalProperty;
  }
  public  void setHistoryPageBeans(List<History> historyPageBeans){
   	 this.historyPageBeans =historyPageBeans  ;
  }
  public  int getStart( ) {
   	 return this.start;
  }
  public  int getLimit( ) {
   	 return this.limit;
  }
  public  int getTotalProperty( ) {
   	 return this.totalProperty;
  }
  public    List<History> getHistoryPageBeans(){
   	 return this.historyPageBeans   ;
  }
  public  String getInfo( ) {
   	 return this.info;
  }
  public  void setInfo(String info){
   	 this.info = info ;
  }
  public  boolean getSuccess( ) {
   	 return this.success;
  }
  public  void setSuccess(boolean success){
   	 this.success = success ;
  }

  @Action(value="insertHistory",results = {@Result(name = "success", type = "json")})
  public String  insertHistory() throws Exception{
   	success = false ;
   	info = "" ;
  	History bean = new History();
  	bean.setDatestr(this.datestr); 
  	bean.setTypestring(this.typestring); 
  	bean.setSerialnumber(this.serialnumber); 
  	bean.setPrice(this.price); 
  	bean.setPeijian(this.peijian); 
  	bean.setRefStorehouseDbid(this.refStorehouseDbid); 
  	bean.setCreateDate(this.createDate); 
	historyService.insert(bean);
   	success = true ;
   	info = "Add Successful" ;
   	return SUCCESS;
  }

  @Action(value="queryHistory",results = {@Result(name = "success", type = "json")})
  public String  queryHistory() throws Exception{
  	History bean = new History();
  	bean.setDbid(this.dbid); 
  	bean.setDatestr(this.datestr); 
  	bean.setTypestring(this.typestring); 
  	bean.setSerialnumber(this.serialnumber); 
  	bean.setPrice(this.price); 
  	bean.setPeijian(this.peijian); 
  	bean.setRefStorehouseDbid(this.refStorehouseDbid); 
  	bean.setCreateDate(this.createDate); 
	historyService.selectByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="updateHistory",results = {@Result(name = "success", type = "json")})
  public String  updateHistory() throws Exception{
   	success = false ;
   	info = "" ;
  	History bean = new History();
  	bean.setDbid(this.dbid); 
  	bean.setDatestr(this.datestr); 
  	bean.setTypestring(this.typestring); 
  	bean.setSerialnumber(this.serialnumber); 
  	bean.setPrice(this.price); 
  	bean.setPeijian(this.peijian); 
  	bean.setRefStorehouseDbid(this.refStorehouseDbid); 
  	bean.setCreateDate(this.createDate); 
  	bean =historyService.selectByPrimaryKey(bean);
  	bean.setDbid(this.dbid); 
  	bean.setDatestr(this.datestr); 
  	bean.setTypestring(this.typestring); 
  	bean.setSerialnumber(this.serialnumber); 
  	bean.setPrice(this.price); 
  	bean.setPeijian(this.peijian); 
  	bean.setRefStorehouseDbid(this.refStorehouseDbid); 
  	bean.setCreateDate(this.createDate); 
	historyService.updateByPrimaryKeySelective(bean);
   	success = true ;
   	info = "Update Successful" ;
   	return SUCCESS;
  }

  @Action(value="deleteHistory",results = {@Result(name = "success", type = "json")})
  public String  deleteHistory() throws Exception{
  	History bean = new History();
  	bean.setDbid(this.dbid); 
  	bean.setDatestr(this.datestr); 
  	bean.setTypestring(this.typestring); 
  	bean.setSerialnumber(this.serialnumber); 
  	bean.setPrice(this.price); 
  	bean.setPeijian(this.peijian); 
  	bean.setRefStorehouseDbid(this.refStorehouseDbid); 
  	bean.setCreateDate(this.createDate); 
	historyService.deleteByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="listHistory",results = {@Result(name = "success", type = "json")})
  public String  listHistory() throws Exception{
 	QryCondition qry = RequestUtil.getQryCondition(   (javax.servlet.http.HttpServletRequest)com.opensymphony.xwork2.ActionContext.getContext().get(org.apache.struts2.ServletActionContext.HTTP_REQUEST)); 	PageBean pageBean = new PageBean();
	pageBean.setPageSize( limit );
	pageBean.setStartCount( start );
	totalProperty =historyService.getTotalRecords( qry, pageBean );
	historyPageBeans =historyService.getOnePageBeans( qry, pageBean );
   	return SUCCESS;
  }

  @Action("index")
  public String index() throws Exception{
   	return SUCCESS;
  }

}
